﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Infrastructure;
using Enterprise.Model.Note;
using Enterprise.Service.Note;
namespace Enterprise.UI.Web.Modules.Notice
{
    public partial class NewNotice : Enterprise.Service.BasePage
    {
        protected DateTime dt = (DateTime)Utility.sink("dt", Utility.MethodType.Get, 0, 0, Utility.DataType.Date);
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BtnSave_OnClick(object sender, EventArgs e)
        {
            string _note = "操作成功";
            try
            {
                NoteService nService = new NoteService();
                NoteEntity entity = new NoteEntity();
                entity.DB_Option_Action = "Insert";
                entity.NUSERID = Utility.Get_UserId;
                entity.NCREATETIME = dt;
                entity.NTITLE = (string)Utility.sink(tb_Title.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
                entity.NREMARK = (string)Utility.sink(tb_Content.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
                entity.NISREMIND = (int)Utility.sink(tb_Remind.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Int);
                //签收范围格式@1,4,5
                string rcv_users = rcv_users_value.Value;
                rcv_users = rcv_users.TrimEnd(',');
                entity.NREMINDUSERS = rcv_users;
                entity.NREMINDTIME = (DateTime)Utility.sink(tb_RemindTime.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Date);
                if (entity.NISREMIND == 1 && entity.NREMINDTIME == DateTime.MaxValue)
                {
                    Utility.ShowMsg(this.Page, "如果备忘需要提醒，请设置提醒时间");
                }
                else
                {
                    nService.NoteExecute(entity);
                }
            }
            catch (Exception ex)
            {
                _note = ex.Message;
            }
            Utility.ShowMsg(this.Page, "OK", this.Tran(_note), "Notices.aspx?dt=" + dt);
        }
    }
}